package com.zwk.gulimall.product.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.zwk.common.utils.PageUtils;
import com.zwk.gulimall.product.entity.AttrAttrgroupRelationEntity;
import com.zwk.gulimall.product.event.AttrEvent;
import org.springframework.context.event.EventListener;

import java.util.Map;

/**
 * 属性&属性分组关联
 *
 * @author zhuwenkang
 * @email zhuwenkang@gmail.com
 * @date 2022-12-30 22:47:10
 */
public interface AttrAttrgroupRelationService extends IService<AttrAttrgroupRelationEntity> {

    PageUtils queryPage(Map<String, Object> params);

    @EventListener(classes = AttrEvent.class,condition = "#event.getType()==T(com.zwk.common.constant.EventType).UPDATE")
    void updateRelation(AttrEvent event);

    @EventListener(classes = AttrEvent.class,condition = "#event.getType()==T(com.zwk.common.constant.EventType).SAVE")
    boolean saveRelation(AttrEvent event);

    /**
     * 同步移除属性的关联
     * @param event
     * @return
     */
    @EventListener(classes = AttrEvent.class,condition = "#event.getType()==T(com.zwk.common.constant.EventType).REMOVE")
    boolean removeRelationByAttr(AttrEvent event);
}

